Chris Pollett > Old Classes >
CS174

( Print View )

Grades: [Sec1]  [Sec2]

Submit: [Sec1]  [Sec2]

Course Info:
  [Texts & Links]
  [Topics]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]

Practice Exams:
  [Mid1]  [Mid2]  [Final]

                            












CS174 Spring 2002Practice Midterm 2

The practice midterm is below. Here are some facts about the actual midterm: (a) The midterm will be in class . (b) It is closed book, closed notes. Nothing will be permitted on your desk except your pen (pencil) and test. (c) You should bring photo ID. (d) There will be more than one version of the test. Each version will be of comparable difficulty. (e) If your cell-phone or beeper goes off you will be excused from the test at that point and graded on what you have done till your excusal. (f) One problem (less typos) on the actual test will be from the practice test.

  1. Write a servlet which initially outputs a form that prompts the user to enter a number. When this form is submitted it outputs a second form which prompts the user to enter a number. Finally, when it recieves this form, it outputs a page which says what the two numbers where. Use hidden variables in a nontrivial way.
  2. Repeat Problem 1 this time, however, use HttpSession instead of hidden variables.
  3. Give an example of the HTTP that would be sent by a server www.buy.com to set a cookie with name Bob with value 52. You can make up values for any cookie info not provided.
  4. Write an HTML page which contains a form and some Javascript. The form has a text input field and a submit button. Whenever the form is submitted, an alert box pops up if the text input data contains the letter h.
  5. Explain with an example how to use a file and the class Properties to read data into a Java program.
  6. Explain how to pass information to a servlet concerning connecting to a database using a web.xml file.
  7. Which of the following servlet methods are called everytime the servlet is requested by the client: (a) init, (b) destroy, (c) service. When are the others called?
  8. Explain how to access the underlying HttpServletRequest and HttpServletResponse objects of the Servlet a given JSP gets mapped to.
  9. Write a Java code fragment that creates a Connection object to the ORCL database on port 1521 of sigma.mathcs.sjsu.edu. You may assume your login and password are Scott Tiger.
  10. Give the SQL neccessary to insert a row for the employee John Smith, 000-00-0000, 50000, 3 into the Employee table.